package com.lpy.book.dao;

import com.lpy.book.model.BorrowDetail;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;

import java.sql.SQLException;

public class BorrowDetailDao {
    public int add(Connection con, BorrowDetail borrowDetail) throws SQLException {
        String sql = "insert into borrowdetail (user_id, book_id, status, borrow_time) values (?,?,?,?);";

        PreparedStatement ps = (PreparedStatement) con.prepareStatement(sql);

        ps.setInt(1, borrowDetail.getUserId());
        ps.setInt(2, borrowDetail.getBookId());
        ps.setInt(3, borrowDetail.getStatus());
        ps.setLong(4, borrowDetail.getBorrowTime());

        return ps.executeUpdate();
    }
}
